// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/

mod db;
mod commands;

// #[tauri::command]
// fn greet(name: &str) -> String {
//     format!("Hello, {}! You've been greeted from Rust!", name)
// }

#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
    tauri::Builder::default()
        .plugin(tauri_plugin_opener::init())
        .setup(|app| {
            // 初始化数据库
            db::init_db(app.handle())?;
            Ok(())
        })
        .invoke_handler(tauri::generate_handler![
            commands::create_todo,
            commands::get_todo_by_id,
            commands::update_todo,
            commands::delete_todo,
            commands::update_todo_completion,
            commands::get_todos_by_month,
            commands::get_todos_by_week,
            commands::get_todos_for_day,
            commands::get_todos_by_tag,
            commands::get_all_todos_by_project,
            commands::get_recent_todos_by_project,
            commands::create_project,
            commands::get_all_projects,
            commands::update_project,
            commands::get_all_tags,
            commands::query_todos_generic
        ])
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}
